package com.whcoding.test;

import org.junit.Test;

import java.util.Date;

/**
 * @program: spring-boot-learning
 * @description:
 * @author: whcoding
 * @create: 2022-09-06 19:58
 **/
public class ObjectProperty {


	/**
	 * 获取对象的属性
	 */
	@Test
	public void getObjectPropertyTests() {
		Date date = new Date();
		System.out.println(date.getClass());
	}

	/**
	 * 将数据库格式类型转化为Jdbc格式
	 *
	 * @param jDBCType jdbc的格式类型
	 * @return
	 */
	@Test
	public String convertToJdbc(String jDBCType) {
		String javaTypeStr = null;
		switch (jDBCType) {
			case "CHAR":
				javaTypeStr = "String";
				break;
			case "VARCHAR":
				javaTypeStr = "String";
				break;
			case "LONGVARCHAR":
				javaTypeStr = "String";
				break;
			case "NUMERIC":
				javaTypeStr = "java.math.BigDecimal";
				break;
			case "DECIMAL":
				javaTypeStr = "java.math.BigDecimal";
				break;
			case "BIT":
				javaTypeStr = " boolean";
				break;
			case "BOOLEAN":
				javaTypeStr = "boolean";
				break;
			case "TINYINT":
				javaTypeStr = "byte";
				break;
			case "SMALLINT":
				javaTypeStr = "short";
				break;
			case "INTEGER":
				javaTypeStr = "INTEGER";
				break;
			case "BIGINT":
				javaTypeStr = "long";
				break;

			case "REAL":
				javaTypeStr = "float";
				break;
			case "FLOAT":
				javaTypeStr = "double";
				break;
			case "BINARY":
				javaTypeStr = "double";
				break;
			case "VARBINARY":
				javaTypeStr = "byte[]";
				break;
			case "LONGVARBINARY":
				javaTypeStr = "byte[]";
				break;

			case "DATE":
				javaTypeStr = "byte[]";
				break;
			case "TIME":
				javaTypeStr = "byte[]";
				break;
			case "TIMESTAMP":
				javaTypeStr = "byte[]";
				break;
			case "CLOB":
				javaTypeStr = "byte[]";
				break;

			case "BLOB":
				javaTypeStr = "Blob";
				break;

			case "ARRAY":
				javaTypeStr = "Array";
				break;
			case "DISTINCT":
				javaTypeStr = "mapping of underlying type";
				break;
			case "STRUCT":
				javaTypeStr = "Struct";
				break;
			case "REF":
				javaTypeStr = "Ref";
				break;
			case "DATALINK":
				javaTypeStr = "java.net.URL[color=red][/color]";
				break;
		}
		return javaTypeStr;
	}
}
